/*!
  \file
  File to implement the image inverter
*/

#include "invertimagesimple.hpp"


// -------------------------------

void InvertImageSimple::Invert( SciGPU::HHV::HHVolume<long,2>& dst,
                                const SciGPU::HHV::HHVolume<long,2>& src ) const {
  SciGPU::HHV::HHVolumeSimple<long,2>::convertor srcConvert( src );
  SciGPU::HHV::HHVolumeSimple<long,2>::convertor dstConvert( dst, false );

  this->Inverter( dstConvert.get(), srcConvert.getConst() );
}




void InvertImageSimple::Inverter( SciGPU::HHV::HHVolumeSimple<long,2>& dst,
                                  const SciGPU::HHV::HHVolumeSimple<long,2>& src ) const {
  
  const long invertVal = 255;
  const long* const srcData = src.start();

  dst.Allocate( src.dimensions() );

  long* const dstData = dst.start();

  for( unsigned int i=0; i<src.hyxels(); i++ ) {
    dstData[i] = invertVal - srcData[i];
  }

}
